<html>
<head><meta charset="utf-8"><title>impl Array · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/impl.20Array.html">impl Array</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="162243228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/impl%20Array/near/162243228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/impl.20Array.html#162243228">(Apr 01 2019 at 14:20)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> , regarding your comment on <a href="https://github.com/rust-lang/rfcs/pull/2545#issuecomment-477958603" target="_blank" title="https://github.com/rust-lang/rfcs/pull/2545#issuecomment-477958603">rust-lang/rfcs#2545</a>, what is the strategy there for allowing operations like deriving Debug or even indexing just into the Array? I tried playing with the code and found that attempting to add <code>Deref</code> or <code>Index</code> impls hit errors about "trait <code>Array</code> cannot be made into an object" due to its use of an associated const.</p>



<a name="162246678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/impl%20Array/near/162246678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/impl.20Array.html#162246678">(Apr 01 2019 at 15:01)</a>:</h4>
<p>Debug works out of the box by adding it as a bound to <code>Array</code>'s definition, but unfortunately almost all other common operations are implemented indirectly via <code>Unsize</code>, so every use site would need <code>&amp;FOO as &amp;[T]</code>, which makes my idea unactionable. We'd need some language/compiler magic that would make <code>impl Unsize&lt;T&gt;</code> also allow operations via the unsizing (and as a consequence, also allow <code>U: Unsize&lt;[T]&gt;</code> bounds on generic functions to allow indexing into values of type <code>U</code>. I wonder if we'd get these automatically by implementing <code>Deref</code> for all array types up to length 32.</p>



<a name="162248516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/impl%20Array/near/162248516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/impl.20Array.html#162248516">(Apr 01 2019 at 15:19)</a>:</h4>
<p>Hmm I thought I tried adding <code>Debug</code> as a bound and found it did not work</p>



<a name="162248603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/impl%20Array/near/162248603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/impl.20Array.html#162248603">(Apr 01 2019 at 15:20)</a>:</h4>
<p>can one make it a bound that is conditional on whether <code>T: Debug</code> ?</p>



<a name="162308820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/impl%20Array/near/162308820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/impl.20Array.html#162308820">(Apr 02 2019 at 07:02)</a>:</h4>
<p>Ah no, probably not.</p>



<a name="162316750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/impl%20Array/near/162316750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/impl.20Array.html#162316750">(Apr 02 2019 at 09:20)</a>:</h4>
<p>okay. so basically, the idea doesn't work on any front. <span aria-label="smile" class="emoji emoji-263a" role="img" title="smile">:smile:</span></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>